<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>焦点悬停效果</title>
    <!-- <link rel="stylesheet" href="../style/悬停.css"> -->
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .keydown {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            flex-direction: column;
            gap: 30px;
            background: #1d2b3a;
        }

        .inputBox {
            position: relative;
            width: 250px;
        }

        .inputBox input {
            box-sizing: border-box;
            width: 100%;
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.25);
            border-radius: 5px;
            background: #1d2b3a;
            outline: none;
            color: #fff;
            font-size: 1rem;
            transition: 0.5s;
        }

        .inputBox span {
            position: absolute;
            left: 0;
            padding: 10px;
            pointer-events: none;
            font-size: 1em;
            color: rgba(255, 255, 255, 0.25);
            text-transform: uppercase;
            transition: 0.5s;
        }

        .inputBox input:valid~span,
        .inputBox input:focus~span {
            color: #00dfc4;
            transform: translateX(10px) translateY(-7px) translate3d(0, 0, 0);
            font-size: 10px;
            padding: 0 10px;
            background: #1d2b3a;
            border-left: 1px solid #00dfc4;
            border-right: 1px solid #00dfc4;
            letter-spacing: 0.2em;
        }

        .inputBox:nth-child(2) input:valid~span,
        .inputBox:nth-child(2) input:focus~span {
            background: #00dfc4;
            color: #1d2b3a;
            border-radius: 2px;
        }

        .inputBox input:valid~span,
        .inputBox input:focus~span {
            border: 1px solid #00dfc4;
        }
    </style>
</head>

<body>
    <div class="keydown">
        <div class="inputBox">
            <input type="text" required="required">
            <span>Frist Name</span>
        </div>
        <div class="inputBox">
            <input type="text" required="required">
            <span>Last name</span>
        </div>
    </div>
</body>

</html>